package com.project.util;

import com.javaGame.util.CutImage;
import com.project.role.*;

import javax.swing.*;
import java.awt.*;

public class InitImage {
    public static void init(JFrame jf) {
        //媒体追踪器
        MediaTracker tracker = new MediaTracker(jf);
        //加入图片，分为1组
        tracker.addImage(GameMap.mapImage, 1);
        //切割图片，第一个参数为图片路径，第二个参数为切割份数，第三个参数为媒体追踪器，第四个参数为分组
        Boss.bossImg = CutImage.cutOneImage("image/boss/playSpear.png", 18, tracker, 1);
        Girl.girlImage = CutImage.cutOneImage("image/girl/forward.png", 4, tracker, 1);
        GirlBullet.girlBulletImg = CutImage.getSingleImage("image/jbullet/dart.png",tracker,1);
        DogMachine.dogMachineImg = CutImage.cutOneImage("image/enemy/dogmachine.png",4,tracker,1);

        try {
            //1组的图片，等待全部加载完毕后，再一起显示
            tracker.waitForID(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
